import redis

# conn =redis.Redis()
# print(conn)

# conn = redis.StrictRedis(host='localhost',port=6379,db=1,decode_responses=True)
# print(conn)
# conn.set('name','wyh')
# print(conn.get('name'))

#为自己封装redis
class RedisClient():
    '''
    封装集合
    '''

    def __init__(self,dbs):
        self.__conn = redis.StrictRedis(db=1,decode_responses=True)
        self.dbs = dbs

    # 添加
    def put(self,*values):
        self.__conn.sadd(self.dbs,*values)

    # 随机获取value
    def get(self,num=None):
        self.__conn.srandmember(name=self.dbs,number=num)



if __name__ == '__main__':
    dbs = 'wyhset'
    wyh = RedisClient(dbs)

    print(wyh.get())
